<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKDomRangeIterator</title>
	<script src="../../../editor/_source/fckscriptloader.js" type="text/javascript"></script>
	<script src="../_common/manual_test.js" type="text/javascript"></script>
	<script type="text/javascript">

var FCK = {} ;
var FCKConfig = { EnterMode : 'p' } ;

FCKScriptLoader.Load( 'FCKDomRangeIterator' ) ;

	</script>
	<script type="text/javascript">

var targetWindow ;

function InnerLoaded( innerWindow )
{
	targetWindow = innerWindow ;
}

function GetParagraphs()
{
	FCKConfig.EnterMode = document.getElementById( 'xEnterMode' ).value ;

	var iterator = FCKDomRangeIterator.CreateFromSelection( targetWindow ) ;
	iterator.ForceBrBreak		= document.getElementById( 'xBrBreak' ).checked ;
	iterator.EnforceRealBlocks	= document.getElementById( 'xRealBlocks' ).checked ;

	var div = targetWindow.document.createElement( 'div' ) ;

	var msg = '' ;
	var counter = 0 ;

	var para ;
	while ( ( para = iterator.GetNextParagraph() ) )		// Only one =
	{
		div.appendChild( para.cloneNode( true ) ) ;
		msg += '\n---\n' + div.innerHTML ;
		div.innerHTML = '' ;

		counter++ ;
	}

	msg = 'Number of ranges: ' + counter + msg ;

	alert( msg ) ;
}

	</script>
</head>
<body>
	<h1>
		FCKDomRangeIterator</h1>
	<p>
		Enter Mode:
		<select id="xEnterMode">
			<option value='p'>p</option>
			<option value='br'>br</option>
			<option value='div'>div</option>
		</select>
		&nbsp;&nbsp;&nbsp;
		<input id="xBrBreak" type="checkbox" /> Force &lt;br&gt; break
		&nbsp;&nbsp;&nbsp;
		<input id="xRealBlocks" type="checkbox" /> Enforce real blocks
	</p>
	<p>
		<input type="button" value="Get Paragraphs" onclick="GetParagraphs(); return false;" />
	</p>
	<iframe src="test1_inner.html" width="100%" height="450" frameborder="1"></iframe>
</body>
</html>
